Esse trabalho visa apresentar o desempenho dos munícipios gaúchos nos blocos educação, renda e saúde no período de 2007 a 2014. Os dados são baseados no IDESE, um indicador-síntese desenvolvido pela Fundação de Economia e Estatística com o propósito de mensurar o nível de desenvolvimento socioeconômico dos municípios gaúchos, bem como fornecer informações para o planejamento de políticas públicas.
As regiões do Rio Grande do Sul a serem consideradas são as seguintes:
library(dplyr)
library(magrittr)
library(lubridate)
library(ggplot2)
library(skimr)
library(tidyr)
library(highcharter)
library(devtools)
library(mapsBR)
library(sf)
library(leaflet)
library(DT)
#install_github(lgsilvaesilva/mapsBR')
library(rgeos)
idese <- readRDS('data/Idese Municipios 2007-2014.rds')
# Exibir o nome das colunas
colnames(idese)## [1] "TIPO_UNID"
## [2] "COD"
## [3] "NOME"
## [4] "ANO"
## [5] "Bloco Educação"
## [6] "Bloco Educação\\Ensino Fundamental"
## [7] "Bloco Educação\\Ensino Fundamental\\Anos Finais"
## [8] "Bloco Educação\\Ensino Fundamental\\Anos Iniciais"
## [9] "Bloco Educação\\Ensino Médio"
## [10] "Bloco Educação\\Escolaridade Adulta"
## [11] "Bloco Educação\\Pré Escola"
## [12] "Bloco Renda"
## [13] "Bloco Renda\\Apropriação da Renda"
## [14] "Bloco Renda\\Geração da Renda"
## [15] "Bloco Saúde"
## [16] "Bloco Saúde\\Condições Gerais de Saúde"
## [17] "Bloco Saúde\\Condições Gerais de Saúde\\Óbitos por Causas Evitáveis"
## [18] "Bloco Saúde\\Condições Gerais de Saúde\\Óbitos por Causas Mal Definidas"
## [19] "Bloco Saúde\\Longevidade"
## [20] "Bloco Saúde\\Saúde Materno Infantil"
## [21] "Bloco Saúde\\Saúde Materno Infantil\\Consultas Pré Natal"
## [22] "Bloco Saúde\\Saúde Materno Infantil\\Mortalidade de Menores de 5 anos"
## [23] "Idese"
## [24] "População"
# Remoção de caracteres especiais das colunas
names(idese) <- make.names(names(idese))
# Deixar as colunas em lowcase
names(idese) <- tolower(names(idese))
# Renomear algumas colunas
idese <- idese %>%
rename(
bl_edu = bloco.educação,
bl_edu_ef = bloco.educação.ensino.fundamental,
bl_edu_ef_af = bloco.educação.ensino.fundamental.anos.finais,
bl_edu_ef_ai = bloco.educação.ensino.fundamental.anos.iniciais,
bl_edu_em = bloco.educação.ensino.médio,
bl_edu_ea = bloco.educação.escolaridade.adulta,
bl_edu_pre = bloco.educação.pré.escola,
bl_rd = bloco.renda,
bl_rd_aprop = bloco.renda.apropriação.da.renda,
bl_rd_ger = bloco.renda.geração.da.renda,
bl_sd = bloco.saúde,
bl_sd_cond_gerais = bloco.saúde.condições.gerais.de.saúde,
bl_sd_obitos_evitaveis = bloco.saúde.condições.gerais.de.saúde.óbitos.por.causas.evitáveis,
bl_sd_obitos_mal_definido = bloco.saúde.condições.gerais.de.saúde.óbitos.por.causas.mal.definidas,
bl_sd_long = bloco.saúde.longevidade,
bl_sd_materno_infantil = bloco.saúde.saúde.materno.infantil,
bl_sd_consult_pre_natal = bloco.saúde.saúde.materno.infantil.consultas.pré.natal,
bl_sd_morte_menor_5anos = bloco.saúde.saúde.materno.infantil.mortalidade.de.menores.de.5.anos
)
# Sumário rápido do dataset
idese %>%
skim()## Skim summary statistics
## n obs: 3976
## n variables: 24
##
## -- Variable type:factor --------------------------------------------------------------------------------------------------------------------------------------
## variable missing complete n n_unique
## cod 0 3976 3976 497
## nome 0 3976 3976 497
## tipo_unid 0 3976 3976 1
## top_counts ordered
## 430: 8, 430: 8, 430: 8, 430: 8 FALSE
## Ace: 8, Águ: 8, Agu: 8, Aju: 8 FALSE
## Mun: 3976, Con: 0, Coo: 0, Cor: 0 FALSE
##
## -- Variable type:integer -------------------------------------------------------------------------------------------------------------------------------------
## variable missing complete n mean sd p0 p25 p50 p75
## ano 0 3976 3976 2010.5 2.29 2007 2008.75 2010.5 2012.25
## p100 hist
## 2014 <U+2587><U+2587><U+2587><U+2587><U+2587><U+2587><U+2587><U+2587>
##
## -- Variable type:numeric -------------------------------------------------------------------------------------------------------------------------------------
## variable missing complete n mean sd p0
## bl_edu 0 3976 3976 0.65 0.089 0
## bl_edu_ea 0 3976 3976 0.42 0.099 0
## bl_edu_ef 0 3976 3976 0.69 0.066 0
## bl_edu_ef_af 0 3976 3976 0.66 0.067 0
## bl_edu_ef_ai 0 3976 3976 0.72 0.082 0
## bl_edu_em 0 3976 3976 0.77 0.15 0
## bl_edu_pre 0 3976 3976 0.74 0.22 0
## bl_rd 0 3976 3976 0.62 0.11 0
## bl_rd_aprop 0 3976 3976 0.63 0.12 0
## bl_rd_ger 0 3976 3976 0.61 0.14 0
## bl_sd 0 3976 3976 0.83 0.053 0
## bl_sd_cond_gerais 0 3976 3976 0.76 0.06 0
## bl_sd_consult_pre_natal 0 3976 3976 0.75 0.092 0
## bl_sd_long 0 3976 3976 0.88 0.063 0
## bl_sd_materno_infantil 0 3976 3976 0.83 0.062 0
## bl_sd_morte_menor_5anos 0 3976 3976 0.91 0.054 0
## bl_sd_obitos_evitaveis 0 3976 3976 0.63 0.088 0
## bl_sd_obitos_mal_definido 0 3976 3976 0.9 0.065 0
## idese 0 3976 3976 0.7 0.071 0
## população 6 3970 3976 22240.55 78493.34 1191
## p25 p50 p75 p100 hist
## 0.6 0.66 0.72 0.84 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2585><U+2587><U+2583>
## 0.35 0.42 0.49 0.76 <U+2581><U+2581><U+2582><U+2586><U+2587><U+2585><U+2582><U+2581>
## 0.65 0.69 0.73 0.92 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2587><U+2587><U+2581>
## 0.62 0.66 0.7 0.88 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2587><U+2587><U+2581>
## 0.67 0.72 0.77 1 <U+2581><U+2581><U+2581><U+2581><U+2582><U+2587><U+2585><U+2581>
## 0.67 0.77 0.88 1 <U+2581><U+2581><U+2581><U+2581><U+2583><U+2587><U+2587><U+2586>
## 0.58 0.77 0.93 1 <U+2581><U+2581><U+2581><U+2582><U+2583><U+2585><U+2585><U+2587>
## 0.55 0.62 0.7 0.96 <U+2581><U+2581><U+2581><U+2582><U+2587><U+2587><U+2583><U+2581>
## 0.55 0.63 0.72 1 <U+2581><U+2581><U+2581><U+2583><U+2587><U+2587><U+2583><U+2581>
## 0.51 0.6 0.7 1 <U+2581><U+2581><U+2581><U+2585><U+2587><U+2586><U+2583><U+2581>
## 0.8 0.83 0.86 0.93 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2585><U+2587>
## 0.73 0.76 0.8 0.9 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2587><U+2585>
## 0.7 0.77 0.82 0.96 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2585><U+2587><U+2582>
## 0.85 0.89 0.92 1 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2586><U+2587>
## 0.8 0.84 0.87 0.96 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2587><U+2587>
## 0.89 0.92 0.94 1 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2582><U+2587>
## 0.57 0.63 0.69 0.85 <U+2581><U+2581><U+2581><U+2581><U+2582><U+2587><U+2587><U+2582>
## 0.87 0.91 0.93 1 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2582><U+2587>
## 0.65 0.7 0.75 0.89 <U+2581><U+2581><U+2581><U+2581><U+2581><U+2585><U+2587><U+2582>
## 2979.5 5727 14732.25 1480967 <U+2587><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581>
Vamos verificar se há alguma correlação entre os blocos educação, renda e saúde.
idese_corr <- idese %>%
mutate(Educacao = bl_edu, Renda = bl_rd, Saude = bl_sd) %>%
select(Educacao,Renda,Saude)
hchart(cor(idese_corr))Como foi o IDESE do RS ao longo dos anos?
idese %>%
group_by(ano) %>%
summarise(media = mean(idese, na.rm = TRUE)) %>%
ggplot(aes(x = ano, y = media)) +
geom_line() +
ylim(0,1) +
ggtitle("Média IDESE no RS") +
xlab("Ano") + ylab("Média IDESE") +
geom_text(aes(label=round(media,3)),hjust=0.5, vjust=2)Será que houve um avanço no desempenho dos alunos do Ensino Fundamental no RS?
idese %>%
group_by(ano) %>%
summarise(media = mean(bl_edu_ef, na.rm = TRUE)) %>%
ggplot(aes(x = ano, y = media)) +
geom_line() +
ylim(0,1) +
ggtitle("Média das Notas dos Alunos do Ensino Fundamental no RS") +
xlab("Ano") + ylab("Média de Notas") +
geom_text(aes(label=round(media,3)),hjust=0.5, vjust=2)Qual o grupo do Ensino Fundamental que apresentou melhor desempenho na Prova Brasil no RS?
idese %>%
group_by(ano) %>%
summarise(anos_iniciais = round(mean(bl_edu_ef_ai, na.rm = TRUE),3), anos_finais = round(mean(bl_edu_ef_af, na.rm = TRUE),3)) %>%
gather(variable, value, c("anos_iniciais", "anos_finais")) %>%
filter(variable %in% c("anos_iniciais", "anos_finais")) %>%
mutate(value01 = scale(value)) %>%
hchart("line", hcaes(x = ano, y = value, group = variable)) %>%
hc_title(text = "Comparação da Média das Notas entre Alunos do Ensino Fundamental do RS") %>%
hc_xAxis(title = list(text = "Anos")) %>%
hc_yAxis(title = list(text = "Média das Notas")) %>%
hc_yAxis(max = 1)Será que houve um aumento na taxa de matrícula de alunos no Ensino Médio no RS?
idese %>%
group_by(ano) %>%
summarise(media = mean(bl_edu_em, na.rm = TRUE)) %>%
ggplot(aes(x = ano, y = media)) +
geom_line() +
ylim(0,1) +
ggtitle("Taxa de Alunos Matriculados no Ensino Médio no RS") +
xlab("Ano") + ylab("Taxa de Matrículas (%)") +
geom_text(aes(label=round(media,2)*100),hjust=0.5, vjust=2)Quais são as 10 cidades gaúchas que possuíram o melhor desempenho no Ensino Fundamental?
idese %>%
group_by(nome) %>%
summarise(media = round(mean(bl_edu_ef, na.rm = TRUE),3)) %>%
arrange(desc(media)) %>%
slice(1:10) %>%
hchart(type = "treemap",
hcaes(x = nome, value = media, color = media))Como está distribuído o IDESE no RS?
data(regMun) #carrega mapa com os municípios brasileiros
regMun %<>%
st_as_sf() %>%
filter(UF == 'RS') %>%
mutate(NOME = iconv(NOME, from = "UTF-8", to = "latin1"))
idese_mapa <- idese %>%
group_by(cod) %>%
summarise(media = round(mean(idese, na.rm = TRUE)*100,3)) %>%
mutate(cod = as.numeric(as.character(cod)))
xx <- regMun %>%
left_join(
y = idese_mapa,
by = c("COD" = "cod")
)
tooltip <- sprintf("<strong>%s</strong><br>
<br>Taxa: %s<br>",
xx$NOME,
xx$media)
# definindo a paleta de cores
npal <- colorBin("Blues", xx$media)
mapa1 <- leaflet(xx) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addPolygons(fillOpacity = 0,
weight = 0.85,
color = "#000000") %>%
addPolygons(color = ~npal(media),
stroke = F,
weight = 0.1,
fillOpacity = 0.7,
popup = tooltip) %>%
addLegend("bottomright",
pal = npal,
values = ~media,
title = "IDESE")
mapa1Quais são as regiões do RS que possuíram as maiores e menores taxas de adultos com Ensino Médio concluído?
idese_mapa <- idese %>%
group_by(cod) %>%
summarise(media = round(mean(bl_edu_ea, na.rm = TRUE)*100,3)) %>%
mutate(cod = as.numeric(as.character(cod)))
xx <- regMun %>%
left_join(
y = idese_mapa,
by = c("COD" = "cod")
)
tooltip <- sprintf("<strong>%s</strong><br>
<br>Taxa: %s<br>",
xx$NOME,
xx$media)
# definindo a paleta de cores
npal <- colorBin("Blues", xx$media)
mapa1 <- leaflet(xx) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addPolygons(fillOpacity = 0,
weight = 0.85,
color = "#000000") %>%
addPolygons(color = ~npal(media),
stroke = F,
weight = 0.1,
fillOpacity = 0.7,
popup = tooltip) %>%
addLegend("bottomright",
pal = npal,
values = ~media,
title = "Taxa Adultos no EM (%)")
mapa1Como está distribuída a geração de renda no RS?
#install_github(lgsilvaesilva/mapsBR')
idese_mapa <- idese %>%
group_by(cod) %>%
summarise(media = round(mean(bl_rd, na.rm = TRUE)*100,3)) %>%
mutate(cod = as.numeric(as.character(cod)))
xx <- regMun %>%
left_join(
y = idese_mapa,
by = c("COD" = "cod")
)
tooltip <- sprintf("<strong>%s</strong><br>
<br>Taxa: %s<br>",
xx$NOME,
xx$media)
# definindo a paleta de cores
npal <- colorBin("Blues", xx$media)
mapa1 <- leaflet(xx) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addPolygons(fillOpacity = 0,
weight = 0.85,
color = "#000000") %>%
addPolygons(color = ~npal(media),
stroke = F,
weight = 0.1,
fillOpacity = 0.7,
popup = tooltip) %>%
addLegend("bottomright",
pal = npal,
values = ~media,
title = "Taxa Geração Renda")
mapa1Quais são as regiões que apresentaram maior índice de longevidade?
#install_github(lgsilvaesilva/mapsBR')
idese_mapa <- idese %>%
group_by(cod) %>%
summarise(media = round(mean(bl_sd_long, na.rm = TRUE)*100,3)) %>%
mutate(cod = as.numeric(as.character(cod)))
xx <- regMun %>%
left_join(
y = idese_mapa,
by = c("COD" = "cod")
)
tooltip <- sprintf("<strong>%s</strong><br>
<br>Índice de Longevidade: %s<br>",
xx$NOME,
xx$media)
# definindo a paleta de cores
npal <- colorBin("Blues", xx$media)
mapa1 <- leaflet(xx) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addPolygons(fillOpacity = 0,
weight = 0.85,
color = "#000000") %>%
addPolygons(color = ~npal(media),
stroke = F,
weight = 0.1,
fillOpacity = 0.7,
popup = tooltip) %>%
addLegend("bottomright",
pal = npal,
values = ~media,
title = "Taxa Longetividade")
mapa1Será que houve um avanço no índice de longevidade no RS?
idese %>%
group_by(ano) %>%
summarise(media = mean(bl_sd_long, na.rm = TRUE)) %>%
ggplot(aes(x = ano, y = media)) +
geom_line() +
ylim(0,1) +
ggtitle("Taxa de Longevidade no RS") +
xlab("Ano") + ylab("Taxa de Longevidade") +
geom_text(aes(label=round(media,3)),hjust=0.5, vjust=2)Fonte das Regiões: https://pt.wikivoyage.org/wiki/Rio_Grande_do_Sul